<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

        <title>用户管理</title>

        <link href="../../css/mine.css" type="text/css" rel="stylesheet" />
    </head>
    <body>
        <style>
            .tr_color{background-color: #9F88FF}
        </style>
        <div class="div_head">
            <span>
                <span style="float: left;">当前位置是：系统管理-》用户管理</span>
                <span style="float: right; margin-right: 8px; font-weight: bold;">
                    <span onclick="exports()" style="color: blue; cursor: pointer">【导出数据】</span>
                    <a style="text-decoration: none;" href="${pageContext.request.contextPath}/sys/add-ui">【添加】</a>
					<span onclick="deletes()" style="color: blue; cursor: pointer">【删除】</span>
                </span>
            </span>
        </div>
        <div></div>
        <div class="div_search">
            <span>
                <form action="${pageContext.request.contextPath}/sys/list" method="get">
                     姓名：
					<input type="text" name="userName" value="${userName}"  />
					 角色: 
					<input type="text" name="roleName" value="${roleName}"  />
					 所属部门: 
					<input type="text" name="deptName" value="${deptName}"  />
                    <input value="查询" type="submit" />
					
                </form>
            </span>
        </div>
        <div style="font-size: 13px; margin: 10px 5px;">
            <form id="formData" action="/sys/deletes" method="post">
                <input type="hidden" name="method" id="mymethod">
                <table class="table_a" border="1" width="100%">
                <tbody>
						<tr style="font-weight: bold;">						
                        <td width="40px;">序号</td>
                        <td width="30px;"><input type="checkbox" id="checkall" onclick="checkAll()" /></td>
						<td width="80px;">账号</td>
                        <td width="80px;">姓名</td>
                        <td >角色</td>
						<td width="100px;">所属部门</td>                                        
                        <td align="center" width="100px;">操作</td>
                    </tr>
                    <c:forEach items="${pageInfo.list}" var="p">
                    <tr id="product1">
                        <td>${p.id}</td>
                        <td><input type="checkbox"  name="ids" value="${p.id}" onclick="docheckAll()" /></td>
						<td>${p.loginName}</td>
                        <td><a href="updated.jsp">${p.userName}</a></td>
						<td>${p.roleName}</td>
						<td>${p.deptName}</td>
                        <td>
							<a href="${pageContext.request.contextPath}/sys/updated-ui?id=${p.id}">修改</a>
							<a href="${pageContext.request.contextPath}/sys/delete?id=${p.id}">删除</a>
						</td>                        
                    </tr>
                    </c:forEach>
                        <tr>
                            <td colspan="20" style="text-align: center;">
                                <a style="text-decoration: none;" href="${pageContext.request.contextPath}/sys/list?userName=${userName}&roleName=${roleName}&deptName=${deptName}">首页 </a>
                                <a style="text-decoration: none;" href="${pageContext.request.contextPath}/sys/list?pageNum=${pageInfo.prePage<1?1:pageInfo.prePage}&userName=${userName}&roleName=${roleName}&deptName=${deptName}">上一页 </a>
                                <c:forEach var="i" begin="1" end="${pageInfo.pages}">
                                    <a style="text-decoration: none;" href="${pageContext.request.contextPath}/sys/list?pageNum=${i}&userName=${userName}&roleName=${roleName}&deptName=${deptName}">${i}</a>
                                </c:forEach>
                                <a style="text-decoration: none;" href="${pageContext.request.contextPath}/sys/list?pageNum=${pageInfo.nextPage==0 ? pageInfo.pages : pageInfo.nextPage}&userName=${userName}&roleName=${roleName}&deptName=${deptName}">下一页 </a>
                                <a style="text-decoration: none;" href="${pageContext.request.contextPath}/sys/list?pageNum=${pageInfo.pages}&userName=${userName}&roleName=${roleName}&deptName=${deptName}"> 尾页 </a>
                                共${pageInfo.pages}页 每页显示${pageInfo.size}/共${pageInfo.total}条
                            </td>
                        </tr>
                </tbody>
            </table>
            </form>
        </div>
    </body>
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <script>
        var checkall, item;
        checkall = document.getElementById("checkall");
        item = document.getElementsByName("ids");
        //全选框判断：全选 全不选
        function checkAll() {
            for (var i = 0; i <item.length; i++) {
                if(checkall.checked){
                    item[i].checked = true;
                }else{
                    item[i].checked = false;
                }
            }
        }
        //单选框判断:如果单选框被选中的数量和单选框的数量相等的时候全选框选中，反之没有被选中；
        function docheckAll(){
            var count=0;
            for (var i = 0; i <item.length ; i++) {
                if(item[i].checked){
                    count++;
                }
            }
            if(count===item.length){
                checkall.checked = true;
            }else{
                checkall.checked = false;
            }
        }
        function  deletes() {
            //设置隐藏域的值
            document.getElementById("mymethod").value="delete";
            //提交表单
            document.forms[1].submit();
        }
        function exports(){
            //设置隐藏域的值
            document.getElementById("mymethod").value="exports";
            //提交表单
            document.forms[1].submit();
        }
    </script>
</html>